package main

import (
	"fmt"
	"math/rand"
	"time"
)

func send2(ch chan int) {
	for {
		var value = rand.Intn(100)
		ch <- value
		fmt.Printf("send %d\n", value) // 这里没有延时
	}
}

func recv2(ch chan int) {
	for {
		value := <-ch
		fmt.Printf("recv %d\n", value)
		time.Sleep(time.Second)
	}
}

func main() {
	var ch = make(chan int, 1)
	// 子协程循环读
	go recv2(ch)
	// 主协程循环写
	send2(ch)
}
